// 定义函数

function getLocation_bd(cbs, cbe) {
    var geolocation = new BMap.Geolocation();
    geolocation.getCurrentPosition(function (r) {
        if (this.getStatus() == BMAP_STATUS_SUCCESS) {
            var mk = new BMap.Marker(r.point);
            // 纬经度
            localStorage.setItem('locationPoint', r.point.lat + ',' + r.point.lng);
            showPosition(r.point);
        }
        else {
            mui.toast('定位失败,错误码:' + this.getStatus());
            cbe();
            localStorage.removeItem('locationPoint');
        }
    }, {enableHighAccuracy: true});


    function showPosition(point) {
        var geoc = new BMap.Geocoder();
        geoc.getLocation(point, function (rs) {
            var addComp = rs.addressComponents;
            var obj = {
                province: addComp.province, // 省
                cityname: addComp.city, // 城市
                district: addComp.district, // 区
                street: addComp.street, // 街道
                street_number: addComp.street_number, // 街道号码
                formatted_address: rs.formatted_address
            }
            cbs(obj);
        });
    }
}

